using System.Collections;
using UnityEngine;

public class EnemyState_XiaoGuaGua_攻击 : EnemyStateBase_XiaoGuaGua
{
	private Coroutine _Cor_动作中向前力;

	private bool is朝向右边;

	public override void OnEnter()
	{
		Vector2 vector = _Mono.transform.position;
		is朝向右边 = ((Vector2)_Mono._Tsf_玩家.position).x > vector.x;
		if (_Cor_动作中向前力 != null)
		{
			_Mono.StopCoroutine(_Cor_动作中向前力);
		}
		_Cor_动作中向前力 = _Mono.StartCoroutine(Cor_动作中向前力());
		_Mono._Ani.Play("攻击");
		_Timer = _Mono._Dict_Anis_name_time["攻击"];
	}

	public override void OnExit()
	{
		if (_Cor_动作中向前力 != null)
		{
			_Mono.StopCoroutine(_Cor_动作中向前力);
			_Cor_动作中向前力 = null;
		}
	}

	private IEnumerator Cor_动作中向前力()
	{
		_Mono._Rb2D.velocity = Vector2.zero;
		float time = 0f;
		while (time < 0.22f)
		{
			if (!_Mono._Is被定)
			{
				time += Time.deltaTime;
			}
			yield return null;
		}
		_Mono._Rb2D.AddForce(new Vector2((is朝向右边 ? 1 : (-1)) * 40, 0f), ForceMode2D.Impulse);
		_Mono.transform.localScale = new Vector3(is朝向右边 ? 1 : (-1), 1f, 1f);
	}

	public override void OnUpdate()
	{
		_Timer -= Time.deltaTime;
		if (_Timer <= 0f)
		{
			_Mono.ChangeState(StateType_Enemy_XiaoGuai.站立);
		}
	}
}
